<?php
	session_start();
	mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
	mysql_select_db("sapmenet_users");
	$ot = $_POST['ot'];
	$me = $_SESSION['JID'];
	$ms=mysql_query("SELECT chat.message, concat(users.FirstName, ' ', users.LastName) AS fullName, users.ID, chat.from, chat.to FROM chat JOIN users ON users.ID=chat.from WHERE chat.seen=0 AND chat.from={$ot} AND chat.to={$me}");
	while ($res=mysql_fetch_array($ms, MYSQL_NUM))
	{
		echo ("<div class = 'wholeMessage'><div class = 'postingPersonName'>".$res[1]." said: </div><br><div class = 'chatMessageText'><p>".$res[0]."</p></div></div>");
	}
	$hah=mysql_query("UPDATE `chat` SET `seen`=1 WHERE `to` LIKE '".$me."' AND `from`={$ot}");
?>